//package com.jhhc.EngineeringSafety.BaseInfo;
//
//import com.jhhc.EngineeringSafety.BaseInfo.entity.BDMS_ES_FORECASTOBJ_B;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.ForecastBaseInfo;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.ForecastItem;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.MonitorStation;
//import com.jhhc.EngineeringSafety.BaseInfo.entity.result.Point;
//import com.jhhc.EngineeringSafety.BaseInfo.service.BDMS_ES_FORECASTOBJ_BService;
//import com.jhhc.FloodForecast.Sensor.Pojo.BDMS_ST_STBPRP_B;
//import com.jhhc.FloodForecast.Sensor.Service.BDMS_ST_STBPRP_BService;
//import com.jhhc.WaterQuality.BaseInfo.entity.BDMS_YB_FORECASTSCHEME_B;
//import com.jhhc.WaterQuality.BaseInfo.entity.BDMS_YB_FORECASTSTATION_B;
//import com.jhhc.WaterQuality.BaseInfo.entity.result.BasinSchemeInfo;
//import com.jhhc.WaterQuality.BaseInfo.entity.result.ForecastSchemeInfo;
//import com.jhhc.WaterQuality.BaseInfo.entity.result.ForecastStationInfo;
//import com.jhhc.WaterQuality.BaseInfo.service.BDMS_YB_FORECASTSCHEME_BService;
//import com.jhhc.WaterQuality.BaseInfo.service.BDMS_YB_FORECASTSTATION_BService;
//import com.jhhc.utils.JsonResult;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
//
//@Api(value="EngineeringSafetyBaseInfoController",tags={"预报基础信息"})
//@RequestMapping(value = "EngineeringSafety/BaseInfo",headers = "Accept=application/json")
//@RestController("EngineeringSafetyBaseInfoController")
//public class BaseInfoController_old {
//
//    @Autowired
//    private BDMS_YB_FORECASTSCHEME_BService bdms_yb_forecastscheme_bService;
//    @Autowired
//    private BDMS_YB_FORECASTSTATION_BService bdms_yb_forecaststation_bService;
//    @Autowired
//    private BDMS_ST_STBPRP_BService bdms_st_stbprp_bService;
//    @Autowired
//    private BDMS_ES_FORECASTOBJ_BService bdms_es_forecastobj_bService;
//    //GetForecastBaseInfos
//    @ApiOperation("获取预报计算方案列表")
//    @RequestMapping(value = "GetForecastBaseInfos", headers = "Accept=application/json", method = RequestMethod.GET)
//    public JsonResult getForecastBaseInfos(@RequestParam Integer projectId) {
//
//        //创建返回对象
//        List<BasinSchemeInfo> basinSchemeInfos = new ArrayList<>();
//
//        //根据项目id获取方案集合
////        List<BDMS_BA_BASINSCHEME_B> bdms_ba_basinscheme_bs =bdms_ba_basinscheme_bService.queryById(projectId);
////
////        for (BDMS_BA_BASINSCHEME_B bdms_ba_basinscheme_b:bdms_ba_basinscheme_bs){
////            BasinSchemeInfo basinSchemeInfo = new BasinSchemeInfo();
////            BoundaryStationInfo boundaryStationInfo = new BoundaryStationInfo();
////            basinSchemeInfo.setBasinSchemeId(bdms_ba_basinscheme_b.getBschemeid());
////            basinSchemeInfo.setBasinSchemeName(bdms_ba_basinscheme_b.getBschemenm());
////            basinSchemeInfo.setBasin(bdms_ba_basinscheme_b.getBasin());
////            String [] bound =bdms_ba_basinscheme_b.getUpb().split(",");
////            boundaryStationInfo.setBoundaryName(bound[0]);
////            boundaryStationInfo.setStationCode(bound[1]);
////            basinSchemeInfo.setBoundaryStationInfo(boundaryStationInfo);
////            basinSchemeInfo.setForecastReachName(bdms_ba_basinscheme_b.getRivers());
//            List<ForecastSchemeInfo> forecastSchemeInfos = new ArrayList<>();
//            List<BDMS_YB_FORECASTSCHEME_B> bdms_yb_forecaststation_bs = bdms_yb_forecastscheme_bService.queryById2(projectId,"工程安全");
//            for (BDMS_YB_FORECASTSCHEME_B bdms_yb_forecaststation_b:bdms_yb_forecaststation_bs){
//                ForecastSchemeInfo forecastSchemeInfo = new ForecastSchemeInfo();
//                //List<ForecastStationInfo> forecastStationInfos = new ArrayList<>();
//                forecastSchemeInfo.setForecastSchemeId(bdms_yb_forecaststation_b.getFschemeid());
//                forecastSchemeInfo.setForecastSchemeName(bdms_yb_forecaststation_b.getFschemenm());
//                forecastSchemeInfo.setRiverModel(bdms_yb_forecaststation_b.getRivermodel());
//                forecastSchemeInfo.setCalMaxT(bdms_yb_forecaststation_b.getCalmaxt());
//                forecastSchemeInfo.setCalInterval(bdms_yb_forecaststation_b.getCalinterval());
//                forecastSchemeInfo.setCalBackDay(bdms_yb_forecaststation_b.getCalbackt());
//                forecastSchemeInfo.setOrder(bdms_yb_forecaststation_b.getFschemeorder());
//                forecastSchemeInfo.setForecastStationInfos(getStationInfo(projectId,bdms_yb_forecaststation_b.getFschemeid()));
//                forecastSchemeInfos.add(forecastSchemeInfo);
//            }
////            basinSchemeInfo.setForecastSchemeInfos(forecastSchemeInfos);
////            basinSchemeInfos.add(basinSchemeInfo);
//       // }
//
//
//
//
//        JsonResult jsonResult = new JsonResult();
//        jsonResult.setData(forecastSchemeInfos);
//        jsonResult.setSucceeded(true);
//        jsonResult.setStatusCode(200);
//        return jsonResult;
//    }
//
//
//    public   List<ForecastStationInfo> getStationInfo(Integer projectId,String forecastSchemeId){
//        List<ForecastStationInfo> forecastStationInfos = new ArrayList<>();
//        //获取预报站点信息
//        List<BDMS_YB_FORECASTSTATION_B> bdms_yb_forecaststation_bs = bdms_yb_forecaststation_bService.queryById(projectId,forecastSchemeId);
//        //获取站点信息
//        List<BDMS_ST_STBPRP_B> bdms_st_stbprp_bs = bdms_st_stbprp_bService.selectStationByProject(projectId);
//        for (BDMS_YB_FORECASTSTATION_B bdms_yb_forecaststation_b:bdms_yb_forecaststation_bs){
//            ForecastStationInfo forecastStationInfo = new ForecastStationInfo();
//            forecastStationInfo.setForecastStationCode(bdms_yb_forecaststation_b.getFstcd());
//            forecastStationInfo.setForecastStationName(bdms_yb_forecaststation_b.getFstnm());
//            forecastStationInfo.setStationCode(bdms_yb_forecaststation_b.getObsstcd());
//            forecastStationInfo.setStationName(bdms_yb_forecaststation_b.getObsstnm());
//            BDMS_ST_STBPRP_B bdmsStStbprpB =   bdms_st_stbprp_bs.stream().filter(bDMSSTSTBPRPB ->bDMSSTSTBPRPB.getStcd().equals(forecastStationInfo.getStationCode())).findAny().orElse(null);
//            if (bdmsStStbprpB != null) {
//                forecastStationInfo.setLgtd(bdmsStStbprpB.getLgtd());
//                forecastStationInfo.setLttd(bdmsStStbprpB.getLttd());
//            }
//
//            forecastStationInfo.setOrder(bdms_yb_forecaststation_b.getFstationorder());
//            forecastStationInfo.setStationType(bdms_yb_forecaststation_b.getFsttp());
//            forecastStationInfos.add(forecastStationInfo);
//        }
//        return forecastStationInfos;
//    }
//
//    //GetForecastStationInfos
//    @ApiOperation("获取预报站点信息")
//    @RequestMapping(value = "GetForecastStationInfos", headers = "Accept=application/json", method = RequestMethod.GET)
//    public JsonResult getForecastStationInfos(@RequestParam Integer projectId,@RequestParam String forecastSchemeId) {
//        //返回对象
//        //List<ForecastStationInfo> forecastStationInfos = new ArrayList<>();
//
//        JsonResult jsonResult = new JsonResult();
//        jsonResult.setData(getStationInfo(projectId,forecastSchemeId));
//        jsonResult.setSucceeded(true);
//        jsonResult.setStatusCode(200);
//        return jsonResult;
//    }
//
//    //获取预报对象信息
//    @ApiOperation("aaa获取预报对象信息")
//    @RequestMapping(value = "GetForecastObjectInfos", headers = "Accept=application/json", method = RequestMethod.GET)
//    public JsonResult GetForecastBaseInfos(@RequestParam Integer projectId) {
//        //返回对象
//        //List<ForecastStationInfo> forecastStationInfos = new ArrayList<>();
//        JsonResult jsonResult = new JsonResult();
//
//        List<BDMS_ES_FORECASTOBJ_B> bdms_es_forecastobj_bs = bdms_es_forecastobj_bService.queryAllByPId(projectId);
//        List<ForecastBaseInfo> forecastBaseInfos = new ArrayList<>();
//        //根据预报对象分组
//        Map<String, List<BDMS_ES_FORECASTOBJ_B>> typeListGroup = bdms_es_forecastobj_bs.stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getObjforecast, Collectors.toList()));
//        for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> typeList : typeListGroup.entrySet()) {
//            ForecastBaseInfo forecastBaseInfo = new ForecastBaseInfo();
//            List<ForecastItem> forecastItems = new ArrayList<>();
//            forecastBaseInfo.setForecastObject(typeList.getKey());
//            //根据monitor分组
//            Map<String, List<BDMS_ES_FORECASTOBJ_B>> motypeListGroup = typeList.getValue().stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getMonitortype, Collectors.toList()));
//            for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> motypeList : motypeListGroup.entrySet()) {
//                ForecastItem forecastItem = new ForecastItem();
//                List<MonitorStation> monitorStations = new ArrayList<>();
//                forecastItem.setMonitorType(motypeList.getKey());
//                forecastItem.setMonitorTypeId(Objects.requireNonNull(typeList.getValue().stream().filter(bdms_es_forecastobj_b -> bdms_es_forecastobj_b.getMonitortype().equals(motypeList.getKey())).findAny().orElse(null)).getMonitortypeid());
//                Map<String, List<BDMS_ES_FORECASTOBJ_B>> staListGroup = motypeList.getValue().stream().collect(Collectors.groupingBy(BDMS_ES_FORECASTOBJ_B::getStcd, Collectors.toList()));
//                for (Map.Entry<String, List<BDMS_ES_FORECASTOBJ_B>> staList : staListGroup.entrySet()) {
//                    MonitorStation monitorStation = new MonitorStation();
//                    List<Point> points = new ArrayList<>();
//                    monitorStation.setStationCode(staList.getKey());
//                    for (BDMS_ES_FORECASTOBJ_B bdms_es_forecastobj_b : staList.getValue()) {
//                        Point point = new Point();
//                        point.setMonitorName(bdms_es_forecastobj_b.getMonitorname());
//                        point.setMonitorXY(bdms_es_forecastobj_b.getMonitorxy());
//                        point.setMonitorId(bdms_es_forecastobj_b.getMonitorid());
//                        point.setMonitorCode(bdms_es_forecastobj_b.getMonitorcode());
//                        forecastBaseInfo.setForecastObjectId(bdms_es_forecastobj_b.getObjforecastid());
//                        monitorStation.setStationName(bdms_es_forecastobj_b.getStnm());
//                        points.add(point);
//                    }
//                    monitorStation.setPoints(points);
//                    monitorStations.add(monitorStation);
//                }
//                forecastItem.setStations(monitorStations);
//                forecastItems.add(forecastItem);
//            }
//            forecastBaseInfo.setForecastItems(forecastItems);
//            forecastItems.sort(Comparator.comparing(ForecastItem::getMonitorTypeId));
//            forecastBaseInfos.add(forecastBaseInfo);
//        }
//
//
//        jsonResult.setData(forecastBaseInfos);
//        forecastBaseInfos.sort(Comparator.comparing(ForecastBaseInfo::getForecastObjectId));
//        jsonResult.setSucceeded(true);
//        jsonResult.setStatusCode(200);
//        return jsonResult;
//    }
//
//
//}
